//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System;
using System.Security.Principal;

using Mindscape.BackgroundMotion.Model;

namespace Mindscape.BackgroundMotion.Website.Infrastructure
{
  /// <summary>
  /// Base interface for all application controllers
  /// </summary>
  public interface IController
  {
    /// <summary>
    /// Returns the currently authenticated member
    /// </summary>
    Member CurrentMember { get; }

    /// <summary>
    /// Indicates if there is a currently authenticated member on the executing request
    /// </summary>
    bool IsLoggedIn { get; }


    /// <summary>
    /// Returns a value held in the session container
    /// </summary>
    /// <typeparam name="T">The generic type of the returned object</typeparam>
    /// <param name="key">The key to the object</param>
    /// <returns>An object of type T which is known by the requested key</returns>
    T GetSession<T>(string key);

    /// <summary>
    /// Returns a value held in the "query string" parameter container
    /// </summary>
    /// <typeparam name="T">The generic type of the returned object</typeparam>
    /// <param name="key">The key to the object</param>
    /// <returns>An object of type T which is known by the requested key</returns>
    T GetParameter<T>(string key);

    /// <summary>
    /// Redirects to a nominated URL
    /// </summary>
    /// <param name="url">The URL to redirect to</param>
    void RedirectTo(string url);

    /// <summary>
    /// Redirects to a nominated URL and querystring
    /// </summary>
    /// <param name="url">The URL to redirect to</param>
    /// <param name="parameters">The querystring parameters to pass</param>
    void RedirectTo(string url, params string[] parameters);

    /// <summary>
    /// Assigns a value to the session container under a nominated key
    /// </summary>
    /// <typeparam name="T">The generic type of the assigned object</typeparam>
    /// <param name="key">The key to the object</param>
    /// <param name="value">The object</param>
    void SetSession<T>(string key, T value);

    /// <summary>
    /// Removes an object from the session container which matches a nominated key
    /// </summary>
    /// <param name="key">The key to the object</param>
    void RemoveSession(string key);

    /// <summary>
    /// Assigns a new cookie to the cookies collection
    /// </summary>
    /// <param name="name">The name of the cookie</param>
    /// <param name="value">The value of the cookie</param>
    /// <param name="expires">The time at which the cookie expires</param>
    void AddCookie(string name, string value, DateTime expires);

    /// <summary>
    /// Removes a cookie from the cookies collection by a nominated name
    /// </summary>
    /// <param name="name">The name of the cookie</param>
    void RemoveCookie(string name);

    /// <summary>
    /// Returns a cookie value from the cookies collection by a nominated name
    /// </summary>
    /// <param name="name">The name of the cookie</param>
    /// <returns>The value of the cookie which is known by the nominated name</returns>
    string GetCookie(string name);

    /// <summary>
    /// The principal which is currently authorised 
    /// </summary>
    IPrincipal Principal { set; }

    /// <summary>
    /// Returns the Path and Querystring of the current request
    /// </summary>
    string RequestPathAndQuery { get; }

    /// <summary>
    /// Returns the Absolute Path of the current request
    /// </summary>
    string RequestAbsolutePath { get; }
  }
}